(function() {
  app.controller('promoteCtrl', ['$scope', '$location', 'tradeApi', function($scope, $location, tradeApi) {
    $scope.init = function(){
      tradeApi.query({
        funcId: '300002',
        data: {}
      }).then(function(res) {
        $scope.share_url = $location.absUrl().replace($location.path(),'/register') + '?recommend_id=' + res.client_id;
        var url = location.origin + location.pathname + '#!/regist/recommend_id=' + res.client_id;
        $scope.mycode_url = 'http://www.gbtags.com/gb/qrcode?t=' + encodeURIComponent(url);
      });

      tradeApi.query({
        funcId: '300030',
        data: {}
      }).then(function(res) {
        $scope.my_client = res;
      });
    };
  }]);
})();
